package com.spring.test.common.util;

import java.lang.reflect.Field;

public class CommonUtil {
	//Model to Vo
	public static Object getModelToVo(Object model, Object vo) {
		Class<?> cls = model.getClass();
		if (cls != null) {
			Field[] modelFields = cls.getDeclaredFields();
			Field[] voFields = vo.getClass().getSuperclass().getDeclaredFields();
			
			for (int i = 0; i < modelFields.length; i++) {
				try {
					modelFields[i].setAccessible(true);
					voFields[i].setAccessible(true);
					if (voFields[i].getModifiers() != 26) {
						voFields[i].set(vo, modelFields[i].get(model));
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		
		return vo;
	}
}